﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace AudioDemo.View
{
    /// <summary>
    /// test5.xaml 的交互逻辑
    /// </summary>
    public partial class test5 : Window
    {
        public test5()
        {
            InitializeComponent();

            GetLines();
        }

        private void GetLines()
        {
            Paragraph p = richTextBox.Document.Blocks.FirstBlock as Paragraph;
            label.Content = p.Inlines.Count + "," + p.LineHeight;
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            // GetLines();

            DependencyObject currObj = richTextBox.CaretPosition.Parent;
            FrameworkElement fe = currObj as FrameworkElement;
            if (fe != null)
            {
                fe.BringIntoView();
            }
            else
            {
                FrameworkContentElement fce = currObj as FrameworkContentElement;
                if (fce != null)
                {
                    fce.BringIntoView();
                }
            }


        }
    }
}
